<?php

declare(strict_types=1);

namespace app\admin\validate;

use sheep\validate\Backend;

class Index extends Backend
{
    protected $rule = [
        // 登录
        'account' => 'require',
        'password' => 'require',
        'captcha' => 'require|sa_captcha',
        'geetest_challenge' => 'require|sa_captcha',
        'geetest_validate' => 'require',
        'geetest_seccode' => 'require',

        // 修改信息
        'nickname' => 'require',
        'mobile' => 'mobile|sa_me_unique:admin,mobile,id',
        'avatar' => 'require',
        'email' => 'email|sa_me_unique:admin,email,id',
        'password' => 'length:6,16',
    ];

    protected $message  =   [
        // 登录
        'account.require'     => '登录账号必须填写',
        'password.require'     => '登录密码必须填写',
        'captcha.require'     => '验证码必须填写',
        'captcha.sa_captcha'     => '验证码不正确',
        'geetest_challenge.require'     => '请先完成图形验证',
        'geetest_challenge.sa_captcha'     => '请先完成图形验证',
        'geetest_validate.require'     => '请先完成图形验证',
        'geetest_seccode.require'     => '请先完成图形验证',
        // 修改信息
        'nickname.require'     => '昵称必须填写',
        'mobile.mobile'     => '手机号格式不正确',
        'mobile.sa_me_unique'     => '手机号不能重复',
        'avatar.require'     => '头像必须上传',
        'email.email'     => '邮箱格式不正确',
        'email.sa_me_unique'     => '邮箱不能重复',
        'password.length'     => '密码长度必须在 6-16 位',
    ];


    protected $scene = [
        'login_none'  =>  ['account', 'password'],
        'login_code'  =>  ['account', 'password', 'captcha'],
        'login_geetest'  =>  ['account', 'password', 'geetest_challenge', 'geetest_validate', 'geetest_seccode'],
        'update' => ['nickname', 'mobile', 'avatar', 'email', 'password']
    ];
}
